﻿/*
 * LINQ to LDAP
 * http://linqtoldap.codeplex.com/
 * 
 * Copyright Alan Hatter (C) 2010-2012
 * alan.hatter@gmail.com - http://hattercoding.blogspot.com/
 * 
 * This project is subject to licensing restrictions. Visit http://linqtoldap.codeplex.com/license for more information.
 */

using System;
using System.Collections.Generic;
using LinqToLdap.Collections;

namespace LinqToLdap.Mapping
{
    internal class DynamicObjectMapping : IObjectMapping
    {
        public DynamicObjectMapping(string namingContext, IEnumerable<string> objectClasses, string objectCategory, string objectClass = null)
        {
            if (namingContext.IsNullOrEmpty()) throw new ArgumentNullException("namingContext");

            NamingContext = namingContext;
            ObjectCategory = objectCategory;
            if (objectClass != null)
            {
                if (objectClasses != null)
                    throw new ArgumentException("objectClass and objectClasses cannot both have a value.");

                objectClasses = new[] { objectClass };
            }
            ObjectClasses = objectClasses;
        }

        public Type Type
        {
            get { return typeof(DirectoryAttributes); }
        }

        public bool IsForAnonymousType
        {
            get { return false; }
        }

        public string NamingContext { get; private set; }

        public string ObjectCategory { get; private set; }

        public IEnumerable<string> ObjectClasses { get; private set; }

        private ReadOnlyDictionary<string, string> _properties;
        public ReadOnlyDictionary<string, string> Properties
        {
            get { return _properties ?? (_properties = new ReadOnlyDictionary<string, string>(new Dictionary<string, string>())); }
        }

        public IEnumerable<IPropertyMapping> GetPropertyMappings()
        {
            throw new NotSupportedException();
        }

        public IEnumerable<IPropertyMapping> GetUpdateablePropertyMappings()
        {
            throw new NotSupportedException();
        }

        public IPropertyMapping GetPropertyMapping(string name)
        {
            throw new NotSupportedException();
        }

        public IPropertyMapping GetDistinguishedNameMapping()
        {
            throw new NotSupportedException();
        }

        public object Create(object[] parameters)
        {
            throw new NotSupportedException();
        }
    }
}
